package com.ming.ThreadDemo;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.FutureTask;

/**
 * @Auther: tangC
 * @Date: 2020/7/8 16:21
 * @Description:
 */
@Slf4j(topic = "tc.ThreadTest")
public class ThreadTest {

    public static void main(String[] args) throws Exception {
//        Runnable myThread = new MyThread();
//        Thread threadA1 = new Thread(myThread,"A1");
//        Thread threadA2 = new Thread(myThread,"A2");
//        Thread threadB1 = new Thread(myThread,"B1");
//        Thread threadB2 = new Thread(myThread,"B2");
//        Thread threadC1 = new Thread(myThread,"C1");
//        Thread threadC2 = new Thread(myThread,"C2");
//        threadA1.start();
//        threadA2.start();
//        threadB1.start();
//        threadB2.start();
//        threadC1.start();
//        threadC2.start();

        FutureTask<Integer> task = new FutureTask(()->{
            Double x = Math.random()*100;
            log.info("{}++++{}",x.toString(),Thread.currentThread().getName());
            return (int)x.doubleValue();
        });
        Thread thread = new Thread(task,"11");
        Thread  thread2 = new Thread(task,"22");
        thread.start();
        Thread.sleep(1000);
        thread2.start();
    }
}
